<template>
  <div>
    <h1>姓名:{{person.name }}</h1>
    <h1>年龄:{{ person.age }}</h1>
    <button @click="showHello('JJ')">打招呼</button>
    <slot></slot>
  </div>
</template>
<script>
export default {
  name: "Demo",
  beforeCreate() {
    // console.log("beforeCreate")
  },
  props: ["msg","school"],
  setup(props, context) {
    // console.log("setup")
    // console.log(props);
    // console.log(context.attrs);
    console.log(context.slots);
    let person = {
      name: "JJ",
      age: 18
    }

    function showHello(name){
        console.log("showHello..")
        context.emit("hello",name)
    }
    //返回一个对象，常用
    return {
      person,
      showHello 
    };
  }
};
</script>
  
  <style>
</style>
  
 